package mongox

import (
	"context"
	"gitee.com/dn-jinmin/tlog"
	"go.mongodb.org/mongo-driver/mongo"
)

type Logx struct {
	col *mongo.Collection
}

func NewLogxRepo(db *mongo.Database) *Logx {
	return &Logx{
		col: db.Collection("_logx_"),
	}
}

func (l *Logx) Write(ctx context.Context, content *tlog.Content, fields ...tlog.Field) {
	l.col.InsertOne(ctx, content.BuildFields(fields...))
}
